package com.fanketly.funacg2.ui.navigation

import com.fanketly.funacg2.ui.screen.destinations.ShowThisTagScreenDestination
import com.fanketly.funacg2.ui.viewmodels.HomeViewModel
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.navigation.popUpTo
import com.ramcosta.composedestinations.spec.Route

fun DestinationsNavigator.toShowThisTagScreen(
    tag: Int,
    homeViewModel: HomeViewModel,
    popUpTo: Route? = null,
    saveState: Boolean = false,
    launchSingleTop: Boolean = false,
) {
    homeViewModel.isFirstToShowThisTagScreen = true
    navigate(ShowThisTagScreenDestination(tag)) {
        this.launchSingleTop = launchSingleTop
        if (popUpTo != null) {
            popUpTo(popUpTo) {
                if (saveState) this.saveState = true
            }
            if (saveState) restoreState = true
        }
    }
}